#[cfg(feature = "axstd")]
use axstd::println;

use axhal::uart;

pub struct Cam5826M11Ctr {
    uart_system: Option<uart::UartSystem>,
}

impl Cam5826M11Ctr {
    pub fn new() -> Self {
        Self { uart_system: None }
    }

    pub fn setup(&mut self) {
        let mut uart_system = uart::UartSystem::new();
        let uart = uart_system.controller(1).unwrap();

        uart.init_no_irq(100_000_000, 115200);
        let send_data = "get_all";
        uart.put_line_poll(send_data);
        println!("send data {send_data}");

        self.uart_system = Some(uart_system)
    }

    pub fn read(&mut self, buf: &mut [u8]) -> usize {
        let uart = self.uart_system.as_mut().unwrap().controller(1).unwrap();
        uart.read_line_poll(buf)
    }
}
